{%- import "utility.html" as utility with context -%}
{% macro the_content() -%}
  <h3 class="handin-heading">{{ pagetitle }}</h3>
  <table class="table table-hover">
    <tr>
      <th>{{ _('Homework') }}</th>
      {% if showuser -%}
        <th>{{ _('User') }}</th>
      {%- endif %}
      <th>{{ _('Submit Date') }}</th>
      <th>{{ _('Status') }}</th>
      <th>{{ _('Score') }}</th>
      <th style="width: 40%">{{ _('Summary') }}</th>
    </tr>
    {% for handin in the_page.items -%}
    {%- set hw = g.homeworks.get_by_uuid(handin.hwid) -%}
    <tr class="{{ handin.state | handinstyle }}">
      <td class="handin-hw">
        {% if hw -%}
          <a href="{{ url_for('homework', slug=hw.slug) }}">{{ hw.info.name }}</a>
        {%- else -%}
          <span class="text-muted">{{ _('(Deleted)') }}</span>
        {%- endif %}
      </td>
      {% if showuser -%}
        <td class="handin-user">
          {{ handin.user.name }}
        </td>
      {%- endif %}
      <td class="handin-date">
        {{ handin.get_ctime() | datetimeformat }}
      </td>
      <td class="handin-status">
        {{ handin.get_state() }}
      </td>
      <td class="handin-score">
        {% if handin.is_accepted() -%}
          {{ (handin.score * handin.scale) | roundscore }}
        {%- else -%}
          <span class="text-muted">{{ _('No score') }}</span>
        {%- endif %}
      </td>
      <td class="handin-detail">
        {% if handin.result -%}
          {{ handin.get_result() }}
          <a href="{{ url_for('handin_detail', uuid=handin.uuid) }}" style="margin-left: 10px">
            {{ _('More &raquo;') }}
          </a>
        {%- else -%}
          <span class="text-muted">{{ _('No summary') }}</span>
        {%- endif %}
      </td>
    </tr>
    {%- endfor %}
  </table>

  {% if the_page.pages > 1 -%}
  <div class="text-center">
    {{ utility.render_pagination(the_page, request.endpoint, perpage=the_page.per_page, **request.view_args) }}
  </div>
  {%- endif %}
{%- endmacro %}